package com.baitiaojun.elasticsearch.api.impl;

import com.baitiaojun.api.domain.video.Video;
import com.baitiaojun.api.exception.ConditionException;
import com.baitiaojun.elasticsearch.api.VideoApi;
import com.baitiaojun.elasticsearch.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.io.IOException;
import java.util.List;

/**
 * @类名 ElasticsearchVideoApiImpl
 * @描述 TODO
 * @作者 白条君
 * @创建日期 2022/12/20 23:22
 * @版本 1.0
 */
@ApiIgnore
@RestController
public class VideoApiImpl implements VideoApi {

    @Autowired
    private VideoService videoService;

    @Override
    public void saveVideo(Video video) throws ConditionException {
        videoService.save(video);
    }

    @Override
    public List<Video> getPageHomeVideoList(Long lastId, Integer pageSize, String... area) throws IOException {
        return videoService.getPageHomeVideoList(lastId, pageSize, area);
    }

    @Override
    public void updateViewCount(List<Long> videoIds) throws IOException {
        videoService.updateVideo(videoIds);
    }

    @Override
    public void removeVideo(Long id) {
        videoService.removeVideo(id);
    }
}
